/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUILayer;
import javax.swing.table.*;
import java.util.ArrayList;

/**
 *
 * @author Gruppe 4
 */
public class TableModelSum extends DefaultTableModel{
    private ArrayList<SumValues> data;
    private String textfield;

    public TableModelSum()
    {
        data = new ArrayList<SumValues>();
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }
    
    public void setData(ArrayList<SumValues> data)
    {
        this.data = data;
        fireTableDataChanged();
    }

    public ArrayList<SumValues> getData() {
        return data;
    }
    
    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public int getRowCount() 
    {
        if(data == null)
        {
            return 0;
        }
        else
        {
            return data.size();
        }
    }

    @Override
    public String getColumnName(int column) {
        String columnName = "";
        switch(column)
        {
            case 0:
            columnName = "Netto i alt";
            break;  
            case 1:
            columnName = "Brutto i alt";
            break;   
            case 2:
            columnName = "Difference";
            break;  
            case 3:
            columnName = "Rabat Kr";
            break;
            case 4:
            columnName = "Rabat %";
            break;
        }        
        return columnName;
    }
    
    @Override
    public Object getValueAt(int row, int column) 
    {
        Object value = null;
            
            switch(column)
        {
            case 0:
                value = data.get(row).getNettoTotal();
                break;
            case 1:
                value = data.get(row).getBruttoTotal();
                break;
            case 2:
                value = data.get(row).getDifferenceTotal();
                break;
            case 3:
                value = data.get(row).getDiscountKr();
                break; 
            case 4:
                value = data.get(row).getDiscountPercent();
                break;
        }     
        return value;
    }    
    
    public void setText(String text)
    {
        textfield = text;
    }      
}
